// 封装模拟的首页数据
// mock数据模拟
import Mock from "mockjs";
// 图表数据

export default {
  getTableData: () => {
    return {
      code: 200,
      data: {
        tableData: [
          {
            name: "oppo",
            todayBuy: 500,
            monthBuy: 2500,
            totalBuy: 22000,
          },
          {
            name: "vivo",
            todayBuy: 480,
            monthBuy: 2300,
            totalBuy: 20500,
          },
          {
            name: "Huawei",
            todayBuy: 620,
            monthBuy: 2800,
            totalBuy: 25000,
          },
          {
            name: "Xiaomi",
            todayBuy: 550,
            monthBuy: 2600,
            totalBuy: 23500,
          },
          {
            name: "Apple",
            todayBuy: 700,
            monthBuy: 3200,
            totalBuy: 28000,
          },
          {
            name: "Samsung",
            todayBuy: 450,
            monthBuy: 2200,
            totalBuy: 19000,
          },
          {
            name: "OnePlus",
            todayBuy: 380,
            monthBuy: 1900,
            totalBuy: 16000,
          },
          {
            name: "Realme",
            todayBuy: 420,
            monthBuy: 2100,
            totalBuy: 18000,
          },
          {
            name: "Meizu",
            todayBuy: 320,
            monthBuy: 1600,
            totalBuy: 14000,
          },
          {
            name: "Nokia",
            todayBuy: 280,
            monthBuy: 1400,
            totalBuy: 12000,
          },
        ],
      },
      msg: "asdknk",
    };
  },

  getCountData: () => {
    return {
      code: 200,
      data: [
        {
          name: "今日支付订单",
          value: 1234,
          icon: "SuccessFilled",
          color: "#2ec7c9",
        },
        {
          name: "今日收藏订单",
          value: 210,
          icon: "starFilled",
          color: "#ffb980",
        },
        {
          name: "今日未支付订单",
          value: 1234,
          icon: "GoodsFilled",
          color: "#5ab1ef",
        },
        {
          name: "本月支付订单",
          value: 1234,
          icon: "SuccessFilled",
          color: "#2ec7c9",
        },
        {
          name: "本月收藏订单",
          value: 210,
          icon: "starFilled",
          color: "#ffb980",
        },
        {
          name: "本月未支付订单",
          value: 1234,
          icon: "GoodsFilled",
          color: "#5ab1ef",
        },
      ],
    };
  },

  // 模拟生成统计数据的函数
  getChartData: () => {
    // 定义品牌列表
    const brands = ["苹果", "vivo", "oppo", "魅族", "三星", "小米"];
    // 初始化一个空数组来存储随机生成的订单数据
    const orderList = [];

    // 生成 7 天的随机订单数据
    for (let i = 0; i < 7; i++) {
      const orderData = {};
      brands.forEach((brand) => {
        // 生成 100 到 8000 之间的随机整数作为该品牌的订单量
        orderData[brand] = Mock.Random.float(100, 8000, 0, 0);
      });
      orderList.push(orderData);
    }

    // 生成日期数组
    const dates = [];
    const startDate = new Date("2019-10-01");
    for (let i = 0; i < 7; i++) {
      const date = new Date(startDate);
      date.setDate(date.getDate() + i);
      const formattedDate = date.toISOString().split("T")[0].replace(/-/g, "");
      dates.push(formattedDate);
    }

    return {
      code: 200,
      data: {
        // 饼图数据
        videoData: [
          { name: "小米", value: 2999 },
          { name: "苹果", value: 5999 },
          { name: "vivo", value: 1500 },
          { name: "oppo", value: 1999 },
          { name: "魅族", value: 2200 },
          { name: "三星", value: 4500 },
        ],
        // 柱状图数据
        userData: [
          { date: "周一", new: 5, active: 200 },
          { date: "周二", new: 10, active: 500 },
          { date: "周三", new: 12, active: 550 },
          { date: "周四", new: 60, active: 800 },
          { date: "周五", new: 65, active: 550 },
          { date: "周六", new: 53, active: 770 },
          { date: "周日", new: 33, active: 170 },
        ],
        // 折线图数据
        orderData: {
          date: dates,
          data: orderList,
        },
        // 表格数据
        tableData: [
          { name: "oppo", todayBuy: 500, monthBuy: 3500, totalBuy: 22000 },
          { name: "vivo", todayBuy: 300, monthBuy: 2200, totalBuy: 24000 },
          { name: "苹果", todayBuy: 800, monthBuy: 4500, totalBuy: 65000 },
          { name: "小米", todayBuy: 1200, monthBuy: 6500, totalBuy: 45000 },
          { name: "三星", todayBuy: 300, monthBuy: 2000, totalBuy: 34000 },
          { name: "魅族", todayBuy: 350, monthBuy: 3000, totalBuy: 22000 },
        ],
      },
    };
  },
};
